"""author: wenyao
   data: 2021/5/6
   project: devopscmdb
"""
#python的多态
#python里不支持多态，python处处是多态

class zhifubao():
    def pay(self):
        print("this is zhifubao pay")

class weixin():
    def pay(self):
        print("this is weixin pay")

class wangyibao():
    def pay(self):
        print("this is wangyibao pay")

zhi = zhifubao()
wei = weixin()
wang = wangyibao()

def pay(obj):  #python里崇尚鸭子类型， 不管obj属于哪个类， 只要有pay
    obj.pay()

pay(zhi)
pay(wei)


######java
#1、python
# def func1(name):
#     print(name)
#
# func1("wy")
# func1(1)

# 2、java
# void sayMessage(String message)
class PAY():
    def pay(self):
        print("pay pay")

class zhifubao(PAY):
    def pay(self):
        print("this is zhifubao pay")

class weixin(PAY):
    def pay(self):
        print("this is weixin pay")

class wangyibao(PAY):
    def pay(self):
        print("this is wangyibao pay")

zhi = zhifubao()
wei = weixin()
wang = wangyibao()

def pay(PAY obj):
    obj.pay()

pay(zhi)
pay(wei)

#python动态语言

#python中不支持多态 语法上的多态 不需要额外实现多态代码
#按照多态的严格语法 不属于多态 （父类作为参数，传递子类的对象）

#python里处处是多态 python是一个动态类型语言，本身就实现了多态，
# 崇尚鸭子类型

#不关心对象是什么类型，到底是不是鸭子，只关心行为。